package cc.htdf.gwc.radar.aspect;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import whisper.common.exception.AbstractRuntimeException;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by JT on 2017/11/15.
 */
@RestControllerAdvice
public class ControllerExceptionAspect {


    @ExceptionHandler(value = AbstractRuntimeException.class)
    public Map patternExceptionHadnler(AbstractRuntimeException exception) {
        Map body = new HashMap(2);
        body.put("code", exception.getCode());
        body.put("message", exception.getMessage());
        return body;
    }
}
